<template>
	<view>
		<scroll-view scroll-y style='height:100vh;'>
		  
		  <view class='top flex-wrap flex-direction-row'>
		       <image v-if="!isLogin" src="../../static/my/default.png" class='img'></image>
			   <image v-else src="../../static/my/daxia.png" class='img'></image>
			   <view @click="goLoginPage">
				   <view class='text'>{{isLogin? name :'登录'}}</view>
			   </view>
		  </view>
		  <view class='icon'>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/pending_payment.png' mode="aspectFit"></image>
		      <text>待审批</text>
		    </navigator>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/pending_delivery.png' mode="aspectFit"></image>
		      <text>未审批</text>
		    </navigator>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/already_shipped.png' mode="aspectFit"></image>
		      <text>审批通过</text>
		    </navigator>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/completed.png' mode="aspectFit"></image>
		      <text>审批失败</text>
		    </navigator>
		  </view>
		
		  <!-- <navigator url="../index/search/search?search=0" class='item'>
		    <view class='left'>
		      我的收藏
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator> -->
		  
		  <navigator url="returnlist/returnlist" class='item'>
		    <view class='left'>
		      工作记录
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		  
		  <navigator url="returnlist/returnlist" class='item'>
		    <view class='left'>
		      修改密码
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		
		  <navigator style="display: none;" class='item'>
		    <view class='left'>
		      联系客服
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		
		  <button style="display: none;" class="contact" open-type='contact'/>
		  
		  <navigator @click="logout" url="" class='item'>
		    <view class='left'>
		      退出登录
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		  
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLogin: false,
				name: ''
			}
		},
		onLoad() {
			var name = uni.getStorageSync("username")
			if (name != ""){
				this.isLogin = true
				this.name = name
			}
		},
		methods: {
			goLoginPage(){
				if(!this.isLogin) {
					uni.navigateTo({ url: 'login/login' })
				}
			},
			
			logout(){
				let that = this
				uni.showModal({
				  title: '确定退出登录吗？',
				  success (res) {
				      if (res.confirm) {
							try {
								uni.removeStorageSync('userid')
								uni.removeStorageSync('username')
								that.isLogin = false
							} catch (e) {
								that.$uniApi.tipMsg("退出登录失败")
								return
							}	
							that.$uniApi.tipMsg("退出登录成功")
							setTimeout(function(){
								uni.navigateTo({
									url: 'login/login'
								})
							},1500)
				      } 
				    }
				})
			}
		}
	}
</script>

<style>
@import url("my.css");
</style>
